
//liuweibo add start 20120326
package com.android.matmanual;



import com.android.matmanual.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



public class FactoryTestResultListAdapter extends BaseAdapter {
	
	private Context mContext;
	private final LayoutInflater mLayoutInflater;
		    
	String[] mName;  
	String[] mResult;  
	int mCount;
	
	public FactoryTestResultListAdapter(Context context,String[] name,String[] result,int count) {
		super();
		mContext = context;
		mCount = count;
		mName = name;
		mResult = result;
		mLayoutInflater = LayoutInflater.from(context);
	}
	
    public int getCount() {
    	return mCount;
    }
	
	
	public Object getItem(int position) {
		return null;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewGroup mView;
		if (convertView == null) {
			mView  = (ViewGroup) mLayoutInflater.inflate(
					R.layout.factory_test_result_list_item, parent, false);;
		} else {
			mView = (ViewGroup)convertView;
		}
		TextView num = (TextView) mView
				.findViewById(R.id.num);
		
		TextView name = (TextView) mView
				.findViewById(R.id.name);
		TextView result = (TextView) mView
				.findViewById(R.id.result);
		if(position == (mCount-1))
		{
			num.setText(Integer.toString(position+1));
			name.setText(mName[position]);
			result.setText("");
		}
		else
		{
			num.setText(Integer.toString(position+1));
			name.setText(mName[position]);
			result.setText(mResult[position]);
			if(mResult[position].equals(mContext.getResources().getString(R.string.success)))
			{
				result.setTextColor(0xff00ff00);
			}
			else
			{
				result.setTextColor(0xffff0000);
			}
		}
		mView.setTag(position+1);
		return mView;
	}

}

//liuweibo end
		 